package com.jerry.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
@Slf4j
@Configuration
@EnableSwagger2WebMvc
@ConfigurationProperties("swagger")
public class KnifeConfig {
    /*@Value("${swagger.config.api-title:API list and test}")
    private String apiTitle = "";*/
    @Value("${swagger.config.base-package}")
    private String basePackage;
    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        log.info(basePackage);
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("apiTitle")
                        .description("# swagger-bootstrap-ui-demo RESTful APIs")
                        .termsOfServiceUrl("http://localhost:8080/swagger-ui.html")
                        .version("1.0")
                        .build())
                .groupName("2.X版本")
                .select()
                .apis(RequestHandlerSelectors.basePackage(basePackage))
                .paths(PathSelectors.any())
                .build();
    }
}
